<?php

include('common_include.php');
include('lib/util/order_include.php');

if (!session_is_registered('my_cart'))
	session_start();

$prodCode = $_GET['prodCode'];
$dao = new SQLitePersistence();
$aProduct = $dao->getProductsByProdCode($prodCode);
$imgPath = $aProduct->getImgPath1();
if ($imgPath == '') {
	$imgPath = $aProduct->getThumbnailPath();
}

list($width, $height, $type, $attr) = getimagesize($imgPath);

if ($width > 250 || $height > 425) {
	if ($width/250 > $height/425) {
		$height = (int) ($height / ($width/250));
		$width = 250;
	} else {
		$width = (int) ($width / ($height/425));
		$height = 425;
	}
}
unset($dao);

if ($_GET['addtocart'] == 'Y' && $_GET['prodCode'])
{
	addToCart($_GET['prodCode']);
	$addStatus = 1;
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
	<title>Winning Marketing</title>
	<link href="style.css" rel="stylesheet" type="text/css" />
<script>
function returnSettlement(prodCode) {
	opener.location = "Settlement.php?prodCode="+prodCode;
	window.close();
}
</script>
</head>
<body>
<div id="content">
	<div>
		    <table width="100%" border="0" align="center" cellspacing="10">
		      <tr><td align="right"><!-- img src="images/Raw/winint.gif" border="0" /-->&nbsp;</td><td><h1><i><b><?php echo $aProduct->getCategory();?></b></i></h1></td></tr>
		      <?php
		      if ($addStatus == 1) {
		      ?>
		      <tr><th colspan="2" align="center"><font color="red">This product has been added to your shopping cart</font></th></tr>
		      <?php
		      }
		      ?>
              <tr valign="middle">
                <td align="center" valign="top" width="270px" height="425px" rowspan="2"><img src="<?php echo $imgPath;?>" border="0" width="<?php echo $width;?>" height="<?php echo $height;?>" /></td>
                <td align="center" width="530px">
                	<table>
                		<tr><td width="20%" align="right"><b>Product Code:&nbsp;&nbsp;&nbsp;&nbsp;</b></td><td width="80%" align="left"><?php echo $aProduct->getProductCode();?></td></tr>
                		<tr><td width="20%" align="right"><b>Product Name:&nbsp;&nbsp;&nbsp;&nbsp;</b></td><td width="80%" align="left"><?php echo $aProduct->getProductName();?></td></tr>
                		<tr><td width="20%" align="right" valign="top"><b>Description:&nbsp;&nbsp;&nbsp;&nbsp;</b></td><td width="80%" align="left"><?php echo $aProduct->getDescription();?></td></tr>
                		<tr><td width="20%" align="right"><b>Size Options:&nbsp;&nbsp;&nbsp;&nbsp;</b></td><td width="80%" align="left"><?php echo $aProduct->getSizeOpt();?></td></tr>
                		<tr><td width="20%" align="right"><b>Color Options:&nbsp;&nbsp;&nbsp;&nbsp;</b></td><td width="80%" align="left"><?php echo $aProduct->getColorOpt();?></td></tr>
                		<tr><td width="20%" align="right"><b>Unit Price:&nbsp;&nbsp;&nbsp;&nbsp;</b></td><td width="80%" align="left">S$ <?php echo $aProduct->getUnitPrice();?></td></tr>
                		<tr><td width="20%" align="right"><b><nobr></>Delivery Mode:&nbsp;&nbsp;&nbsp;&nbsp;</nobr></b></td><td width="80%" align="left">
                			<?php
                				if ($aProduct->getPostAllow() == "Y") {
                					echo "Self Collect / Post";
                				} else {
                					echo "Self Collect";
                				}
                			?>
                		</td></tr>
                		<?php
                		if ($aProduct->getPostAllow() == "Y") {
                		?>
                		<tr><td width="20%" align="right">Shipment Fee:</td><td width="80%" align="left">S$ <?php echo $aProduct->getPostage();?></td></tr>
                		<?php
                		}
                		?>
                	</table>
                </td>
              </tr>
              <tr valign="middle">
                <td align="right" width="530px">
                <div valign="top">
                	<a href="product_display.php?addtocart=Y&prodCode=<?php echo $prodCode; ?>" ><img src="images/Cart.png" border="0" width="60px" height="60px" /></a>
                	<a href="javascript:returnSettlement('<?php echo $prodCode;?>');" ><img src="images/BuyNow.png" border="0" width="60px" height="60px" /></a>
                </div>
                </td>
              </tr>
        </table>
	</div>
</div>
</body>
</html>